<?php
include_once "models/MySqlDataAccessHelper.php";
include_once "objs/MenuPojo.php";


class MenuDao {

    public static function getMenus() {
        $ds = array();
        $sql = "select * from menu";
        $helper = new MySqlDataAccessHelper;

        $helper->open();
        $rs = $helper->executeQuery($sql);
        if (FALSE === $rs) {
            echo mysql_error();
            return $ds;
        } else {
            while ($row = mysql_fetch_array($rs)) {
                $dm = new MenuPojo($row["id"],$row["name"]);
                array_push($ds, $dm);
            }
            $helper->close();
            return $ds;
        }
    }

    public static function insertMenu($name) {
        $sql = sprintf("INSERT INTO menu (name) Values('%s');", $name);
        $helper = new MySqlDataAccessHelper;

        $helper->open();
        $helper->executeUpdate($sql);
        $helper->close();
    }
    
    
}

?>